package br.com.ucb.projFinal.forms.busca;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import br.com.ucb.projFinal.beans.ManipulaEntradaDados;


@SuppressWarnings("serial")
public class ConsultaCodigoBarra extends JPanel{
    		
		private JLabel jlCodigoDeBarraConsulta;
		private JTextField jtfCodigoDeBarraConsulta;
		private JButton jbOk;
		
		
		
	public int recibeCodigoDeBarra(){
		
		
		//getText() returns string
		String i=getJtfCodigoDeBarraConsulta().getText();

		int codigoDeBarraConsulta=Integer.parseInt(i);
		//code for calculation on integer

		/*displaying integer value agn to textfield or any other label */
		return codigoDeBarraConsulta;
		
	}


	public ConsultaCodigoBarra(){
		
			setLayout(new FlowLayout(20,20,20));
			setPreferredSize(new Dimension (700,500));
			
			initObjectsUI();
			add(getJlCodigoDeBarraConsulta());
			add(getJtfCodigoDeBarraConsulta());
			add(getJbOk());
			setLayout(new FlowLayout(40,90,30));
			setBorder(BorderFactory.createLineBorder(Color.blue));
		}

		public void initObjectsUI() {
			setJtfCodigoDeBarraConsulta(new JTextField());
			getJtfCodigoDeBarraConsulta().setPreferredSize( new Dimension(400, 20) );
			setJlCodigoDeBarraConsulta(new JLabel("Consultar Codigo de Barra: "));
			
			
			setJbOk(new JButton(" Consultar "));
			getJbOk().addActionListener((ActionListener) new EncontrarCodigoBarras());

		}


		public JLabel getJlCodigoDeBarraConsulta() {
			return jlCodigoDeBarraConsulta;
		}


		public void setJlCodigoDeBarraConsulta(JLabel jlCodigoDeBarraConsulta) {
			this.jlCodigoDeBarraConsulta = jlCodigoDeBarraConsulta;
		}


		public JTextField getJtfCodigoDeBarraConsulta() {
			return jtfCodigoDeBarraConsulta;
		}


		public void setJtfCodigoDeBarraConsulta(JTextField jtfCodigoDeBarraConsulta) {
			this.jtfCodigoDeBarraConsulta = jtfCodigoDeBarraConsulta;
		}
		
		public JButton getJbOk() {
			return jbOk;
		}


		public void setJbOk(JButton jbOk) {
			this.jbOk = jbOk;
		}
		
}